package com.wiim.adapter;

import java.util.ArrayList;

import com.wiim.model.DanhSachModel;
import com.wiim.nhapnhap.R;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DanhSachAdapter extends BaseAdapter {
	private ArrayList<DanhSachModel> listData;
	private Activity ac;

	static class ViewHolder {
		TextView tvName;
		TextView tvDes;
	}

	public DanhSachAdapter(final Activity _ac, ArrayList<DanhSachModel> _list) {
		this.listData = _list;
		this.ac = _ac;
		// imageLoader = new ImageLoader(context);
	}
	

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listData.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return listData.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			LayoutInflater inflater = LayoutInflater.from(ac);
			convertView = inflater.inflate(R.layout.danhsach_item, null);
			holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
			holder.tvDes = (TextView) convertView.findViewById(R.id.tvDes);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.tvDes.setText(listData.get(position).getDes());
		holder.tvName.setText(listData.get(position).getName());
		return convertView;
	}

}
